MetaTutorials

MetaTutorials

The Tutor is Yours!

Presentation Layer of OSI Model

In this networking article, you will learn about the Presentation Layer of the OSI reference model in detail with its diagram and functions. We will also discuss the protocols used by the presentation layer. 
presentation layer_cover

What is the Presentation Layer of OSI model?

The presentation layer of the OSI Model receives the data from the higher layer and manipulates it according to the required format, and then transmits it over the network. 
This layer is also referred to as the translation layer because it acts as a translator between the two communicating devices. 
presentation layer

This OSI layer mainly deals with the syntax and semantics of the message which it transmits over the network. It maintains the data format and defines the encryption/decryption methods for the sensitive data. 
It is also responsible for reducing the size/bandwidth of the data which is to be transmitted over the network.

Functions of Presentation Layer

The functions of the presentation layer are described below:

1. Translation: The main function of the presentation layer is to translate the message into an acceptable and compatible format for communication between two different devices. 
At the sender node, it translates the data of sender-understandable format into a common format and at the receiver node, it again translates the common format into receiver-understandable format.

2. Encryption/Decryption: Encryption and Decryption techniques are used to maintain data privacy and data integrity. The encryption mechanism is used at the sender device to encrypt the data which is to be transmitted, and the decryption mechanism is used at the receiver device to decrypt the received data.

3. Compression: Data Compression is also another main function performed by the presentation layer. It helps in reducing the size of the data which is to be transferred over the network. Due to this, the speed and efficiency of communication become increase.

4. Character Code Translation: Another aim of the presentation layer is that it also translates the ASCII code/characters to EBCDIC code/characters. 

Protocols of Presentation Layer

Following are the various networking protocols used in the presentation layer for performing its functions:
1. AFP
2. LPA
3. NDR
4. SSL
5. NCP
6. XDR
protocols

AFP (Apple Filling Protocol)

Apple Filling Protocol is a type of communication protocol which is basically designed for providing file services to Mac-based platforms across the network. 

LPP (Lightweight Presentation Protocol)

The Lightweight Presentation Protocol is defined in RFC 1085, which offers the ISO presentation services running on the TCP/IP-based protocol stacks.

NDR (Network Data Representation)

The Network Data Representation is also a presentation protocol which offers various primitive and constructed data types. This protocol represents the data (images, videos, audio, numbers, etc) over the network.

SSL (Secure Socket Layer)

The Secure Socket Layer protocol gives a high level of security to encrypt the data which is being passed between the web browser and web server.  

NCP (Netware Core Protocol)

The Netware Core Protocol is a network protocol which allows users to access files, directories, messages, prints, and other services of the network. Users can run this protocol on Mac OS X, Linux, Microsoft Windows, Windows NT, and Classic Mac OS.

XDR (External Data Representation)

External Data Representation is also another presentation protocol which was introduced in 1987. It is used for communication between different kinds of computer architectures. The process of converting the data from Local to XDR is called encoding. And the process of converting the data from XDR to Local is called decoding. 

Top 10 Samsung Mobile Phones

In this article, we will discuss Top 10 Samsung Mobile Phones with their features and benefits. 
Top10 Samsung mobiles
The word 'Mobile' is like the additional body part that is not attached to the body but important as our body. 
More than 65% of the world's population is using mobile phones, which keeps increasing daily. The world is full of impressive innovations, and technology companies keep surprising us with their technologies. Nowadays, smartphones are grabbing the market like the web net. 

Many brands have established their market for their successful models and the advanced features of smartphones. Technologies like iOS, Android, Windows phones, etc. rule the world. Android is the most famous among the people,  but this article is especially about the android brand, SAMSUNG.
 
Samsung is the biggest name in the Android world, which is a big Korean Brand. If you want to purchase a new phone, then Samsung provides wide variety of phones whose range starts from 10,499 
INR and ends at 1,64,999 INR.
The following list describes the Top 10 Samsung Mobiles:

1. Samsung Galaxy S22 series

As compared to the Samsung Galaxy S21 series, S22 series has many upgraded features which are valuable for user.
s22series
Now, we are going to describe the main features of S22 series models.
The main Features available in Samsung Galaxy S22 Ultra are as follows:
1. Display: 6.8-inch, QHD+,
2. Back Cameras: 12, 10, 10, and 108MP,
3. Front camera: 40MP,
4. Storage: 128, 256, 512GB, 1TB,
5. RAM: 8 or 12GB,
6. Battery: 5,000mAh,
7. Chipset: SD 8 Gen 1 or Exynos 2200, and
8. Software: Android 12.

The main Features available in Samsung Galaxy S22 are as follows:
1. Display: 6.1-inch, FHD+,
2. Back Cameras: 10, 12, and 50MP,
3. Front camera: 40MP,
4. Storage: 128GB or 256GB,
5. RAM: 8GB,
6. Battery: 3,700mAh,
7. Chip-set: SD 8 Gen 1 or Exynos 2200, and
8. Software: Android 12.

The main Features available in Samsung Galaxy S22 Plus are discussed below:
1. Display: 6.6-inch, QHD+,
2. Back Cameras: 10, 12, and 50MP,
3. Front cameras: 40MP,
4. Storage: 128GB or 256GB,
5. RAM: 8GB,
6. Battery: 4,500mAh,
7. Chip-set: SD 8 Gen 1 or Exynos 2200, and
8. Software: Android 12.

The main benefit of buying Samsung S22 series devices is that they give a phenomenal display with an excellent camera, and an integrated style.

2. Samsung Galaxy S21 Ultra

Samsung's Galaxy S21 Ultra is an excellent option as it holds second in the list. Samsung offers the Gorilla Glass Vectus and Armor Aluminum design which is a slightly different set of Phantom finish. 
s21 ultra
Samsung's Galaxy S21 Ultra launched with the Android 11. WQHD+ resolution and an adaptive refresh rate of up to 120Hz, make it great for gaming. 

The few major features of Samsung's Galaxy S21 Ultra are given below: 
1. Display: 6.8-inch, QHD+,
2. Back Cameras: 108, 10, 10, and 12MP,
3. Front camera: 40MP,
4. Storage: 128,256,512GB,
5. RAM: 12 or 16GB,
6. Battery: 5,000mAh,
7. Chip-set: SD 888 or Exynos 2100, and
8. Software: Android 11.

3. Samsung Galaxy Z Fold 3

Samsung always surprises its users with new innovations and techs. So, Samsung introduced the Galaxy Z Fold 3, which is a foldable phone. In Galaxy Z Fold 3, internal and external displays have a 120Hz refresh rate. 
galaxyzfold3
The main features of Galaxy Z Fold 3 are as follows: 
1. Display: 6.2-inch HD+ and 7.6-inch QXGA+,
2. Back Cameras: 12MP, 12MP, and 12MP,
3. Front camera: 10MP and 4MP UDC,
4. Storage: 256 or 512GB,
5. RAM: 12GB,
6. Battery: 4,400mAh,
7. Chipset: Snapdragon 888, and
8. Software: Android 11.

The main benefit of buying this device is that it is great for multitasking. Another good advantage is that it has a Water-resistant design and consistent cameras.

4. Samsung Galaxy Z Flip 3

Samsung always surprises us, and it doesn't mean an end to experimentation. The external display gives the necessary boost, and its notifications are more vivid and larger. 
z flip 3
Some of the main features of the Samsung Galaxy Z Flip 3 are as follows: 
1. Display: 6.7-inch and 1.9-inch,
2. Back Cameras: 12 and 12MP,
3. Front camera: 10MP,
4. Storage: 128 or 256GB,
5. Battery: 3,300mAh,
6. RAM: 8GB,
7. Chipset: Snapdragon 888, and
8. Software: Android 11.

Some pros of buying Samsung Galaxy Z Flip 3 are mentioned below: 
i. It has a water-resistant design,
ii. You can easily afford this foldable device.
iii. And last benefit is that it has an elegant folding design.

5. Samsung Galaxy S21 FE

The Samsung Galaxy S21 FE is a part of the S21 series, but it has launched in a window operating system of its own. 
s 21 FeSome of the major features of the Samsung Galaxy S21 FE are as follows:
1. Display: 6.4-inch, FHD+,
2. Back Cameras: 12, 12, and 8MP,
3. Front camera: 32MP,
4. Storage: 128 or 256GB,
5. Battery: 4,500mAh,
6. RAM: 6 or 8GB,
7. Chipset: Snapdragon 888, and
8. Software: Android 12

The main benefit of this device is that it has a clean design, great long-term support with good cameras.

6. Samsung Galaxy Note 20 Ultra

Samsung Galaxy Note 20 Ultra offers best-in-class performance with top specifications like a 108MP camera, S-Pen Stylus, enormous screen, and good hardware.
Galaxy Note 20 Ultra has an excellent night photography. It has a 120Hz refresh rate.
s20 ultraThe major Features of Samsung Galaxy Note 20 Ultra are mentioned below:
1. Display: 6.9-inch,
2. Colour Dynamic AMOLED,
3. Back Cameras: 108, 12, and 12MP,
4. Front camera: 10MP,
5. Storage: 256GB,
6. Battery: 4,500mAh,
7. RAM: 6 or 8GB,
8. Chipset: Exynos 990, and
9. Software: Android 10.

Some of the good advantages of buying this device are that it has great performance with good battery life and a rich camera experience.

7. Samsung Galaxy A53 5G

The most affordable Samsung mobile phone is Samsung Galaxy A53 5G, which offers everything for your need. 
Samsung Galaxy A53 5G has a Super AMOLED screen with a 120Hz refresh rate. As comparing to the Samsung Galaxy A52 5G, the Samsung Galaxy A53 5G phone offers lots of upgraded features. 
a53 5g
Few major features of the Samsung Galaxy A53 5G are as follows:
1. Display: of 6.5-inch, Full HD+,
2. Cameras: 64, 12, 5, and 5MP,
3. Front camera: 32MP,
4. Storage: 128/256GB,
5. Battery: 5,000mAh,
6. Software: Android 12,
7. Chipset: Exynos 1280,
8. Software: Android 12, and
9. RAM: 4/6/8GB.

The main benefit of buying this device is that it offers solid battery life with good cameras and stereo speakers. 

8. Samsung Galaxy A13

If you want to buy the best 5G mobile in mid Range variant, then Samsung Galaxy A13 is one of the best phones you get from the market. 
a13
Following are the few major features of the Samsung Galaxy A13: 
1. Display: 6.5-inch, HD+,
2. Back Cameras: 50, 2, and 2MP,
3. Front camera: 5MP,
4. Storage: 64GB,
5. RAM: 4GB,
6. Battery: 5,000mAh,
7. Chipset: MediaTek Dimensity 700, and
8. Software: Android 11.

The main advantage of buying this phone is that it has a headphone jack with a decent main camera, and it has a slick design.

9. Samsung Galaxy A03s

For the mid-range variant, Samsung Galaxy A03s seems to be a good option this year. 
Samsung Galaxy A03s brings some good updates under a pocket-friendly range. It has a fingerprint reader instead of software-based security. 
Its screen is 6.5 inches with HD+ resolution. 
a03s
Some main features of Samsung Galaxy A03s are mentioned below: Display: 6.5-inch, HD+,
1. Back cameras: 13, 2, and 2MP,
2. Front camera: 5MP,
3. Battery: 5,000mAh,
4. Storage: 32/64GB,
5. RAM: 3/4GB,
6. Chipset: MediaTek Helio P35, and
7. Software: Android 11.

The main benefit of buying this device is that it uses the latest operating system 3.1 UI with a side-mounted fingerprint reader. Another good advantage is that it also has a great battery life with a 15W fast charger.

10. Samsung Galaxy A73 5G

In march 2022, Samsung introduced its new phone Samsung Galaxy A73 5G smartphone. This new phone has lots of features like fast performance, stereo speakers, a high refresh rate, an all-day battery life with a 25W fast charging, and a great camera. 
In Samsung Galaxy A73, there are many connectivity options like 5G, Wi-Fi, 4G LTE, Bluetooth, GPS, and many more. 
A73 5g
Some of the major features of the Samsung Galaxy A73 5G smartphone are mentioned below: 
1. Display: 6.7-inch, 
2. AMOLED Plus,
3. Back Cameras: 108MP, 12MP, 5MP, and 5MP, 
4. Front camera: 32MP,
5. Battery: 5,000mAh,
6. Storage: 128GB,
7. RAM: 8GB,
8. Chipset: Snapdragon 778G, and
9. Software: Android 12.
The main benefit of buying this device is that it has an excellent 120Hz display with an Attractive design.

String and Vector in Java

In this article, you will learn about the concept of String and Vector in Java programming language in detail with an example. Here, we will also discuss the methods of vector and strings with their description.
String and Vector in Java

What is a String in Java?

A string is a group of different characters, such as the four characters in the string "Java." A string is an immutable object in Java programming, which implies that the string cannot be modified after creation.

There are two ways in which we can make or create Strings:
1. Using New Keyword
2. Using String Literal
Now, you will learn how to create string using new keyword and string literal.

New Keyword

As we know, the compiler only built one object and made both literals point to the string when we assigned the same string object to two separate literals. 

The statements in the following block show how to create a string using new keyword:
String str1 = new String("MetaTutorials");
String str2 = new String("MetaTutorials");
In this instance, the compiler would produce two distinct objects with identical strings in the memory.

String Literal

In Java, string literals are created by specifying the value in the double quotes. 
The following statements show how to create a string using string literals:
String str1 = "MetaTutorials";
String str2 = "Java Tutorial";

Methods of String Class

In Java, there is a string class which gives various methods to perform operations on strings. Few of them are mentioned below:
Methods
Description
concat()        

This method of String class in java adds the string at the end of another string.

compareTo()

This method compares two string.

length()

This method shows the length of the specified string.
replace()

This method replaces the existing string with the new string. 

split()

This method of String class splits the specified string into array of multiple strings.

toLowerCase()

This method converts the upper case characters of string into lower case characters.

toUpperCase()

This method converts the lower case characters of string into upper case characters.

isEmpty()

This String class method checks whether the specified string is empty or not. 


Example of a String:

public class String_Example{  
   public static void main(String args[]){  

String S1 = "MetaTutorials"; //Here, we creare the new string (S1) with the help of string literal. 
char arrS2[]={'J','A','V','A'}; 
String S2 = new String(arrS2); // Here, we convert the character array to the string S2.

String S3 = new String("Strings In Java "); //Here, we create the new string (S3) with the help of new keyword.

//Now, we are going to display all the three strings S1, S2, and S3 with the help of java println function.
System.out.println(S1);  
System.out.println(S2);  
System.out.println(S3);  
   }
}

Output of above code:
MetaTutorials
JAVA
Strings In Java

 

Vector in Java

The Vector is same as the dynamic array in Java which grow its size when elements are added and shrink its size when elements are removed from it. 
In Java language, vectors are found in java.util package and allows you to implement the List interface which provides all the Methods of List interface to use.

Its storage increase in chunks. Each vector makes an effort to optimize storage management by incrementing the capacity. The size of capacity increments when the new element is added. Thus, the capacity is always at least as large as the vector size. It is typically larger. The capacity of a vector can be increased by an application before the specific number of values are inserted. This minimizes the amount of incremental reallocation.

The iterator and list iterator methods of this class return fail-fast iterators that will issue a ConcurrentModificationException when the vector is structurally updated at any point after the initialization of iterator. 

Syntax of Vector in Java

public class Vector<E> extends AbstractList<E> implements List<E>, RandomAccess, Cloneable, Serializable

In this syntax, 
    • E indicates an element.
    • List interfaces are implemented, and AbstractList is extended.
    • It supports the Iterable <E>, collection<E>, List<E>, Cloneable, Serializable, and RandomAccess interfaces.
    • Stack is the direct subclass.

Methods of Vector

Methods
Description

extends(E> c)

This method adds each element from the provided collection.

addAll(int index,

Collection<? extends E> c)

This method adds every element from the given collection to the vector at the given point.

addElement(E obj)

This method increases the size of the vector by one and add element to the vector.

capacity()

This method returns the vector's current capacity.

clear()

Deletes every component from this vector.

clone()

A copy of this vector is given back.

contains(Object o)

This function returns true if the requested element exist in this vector.

containsAll(Collection<?> c)

If this vector includes every element in the given collection, it will return true.

copyInto(Object[] anArray)

This method copies this vector's elements into the designated array.

element(int index)

This method reveals the component located at the given index.

elements()

This List interface method returns a list of the elements that help in creating this vector.

ensureCapacity(int minCapacity)

This method ensures that the vector has enough space to store the minimum number of elements.

equals(Object o)

This method verifies that the given Object and Vector are same or not.

firstElement()

This method shows the first element of this vector, or the item at index 0.

get(int index)

This method shows the element located in this vector at the given point.

hashCode()

This method gives the value of the hash code for this vector.

indexOf(Object o, int index)

This method shows the index of the first occurrence of the given value in vector. If the given element is not found, then the method returns -1.

insertElementAt(E obj, int index)

This method inserts the given object as an element at the given index in the specified vector.

isEmpty()

This method determines if this vector is empty.

iterator()

This method returns an iterator that iterates across the entries in the correct order.

lastElement()

This method returns the vector's last element.

lastIndexOf(Object o)

This function shows the index of the last occurrence of the passed element in the given vector. If the passed element is not found, then the method returns -1.

lastIndexOf(Object o, int index)

This method shows the index of the last occurrence of the given value in vector. If the given element is not found, then the method returns -1.

listIterator()

This method provides an iterator list of the entries in this list as a result (in proper sequence).

listIterator(int index)

This method returns a list iterator from the specified index value.

remove(int index)

This method removes the specified element from the given location in vector.

remove(Object o)

This method removes the passed element from the first instance of the vector. If the element is not exist in the vector, it remains unchanged.

removeAll(Collection<?> c)

This method removes all the elements of those indexes which are passed in this method.

removeAllElements()

This method removes all the elements and sets the size of vector as zero automatically.

removeElement(Object obj)

This method removes the first occurrence from the vector.

removeElementAt(int index)

The component at the provided index is deleted.

removeIf(Predicate<? super E> filter)

Removes all of the collection's components that meet the specified criteria.

removeRange(int fromIndex,

int toIndex)

This method removes all the entries between the given index values. The first index and last index value are also included.

replaceAll(UnaryOperator<E> operator)

This list's elements are replaced with the outcome of applying the operator to each element.

retainAll(Collection<?> c)

This method only keeps the components of this vector present in the given collection.

set(int index, E element)

This method replaces the element at the specified index with the new element.

setElementAt(E obj, int index)

This method replaces the object at the specified index with the new object.

setSize(int newSize)

This method adjusts this vector's size.

size()

This method returns the vector's total number of components.

sort(Comparator<? super E> c)

This method sorts the list in an order that the given comparator has induced.

spliterator()

This method creates a splitter over the items in the list that is late-binding and fail-fast.

subList(int fromIndex, int toIndex)

This method shows all the elements between the given index values. The first index and last index value are also included.

toArray()

This method returns an array of the vector elements.


Example of Vector in Java

import java.util.*;
// This is the main class
class MetaTutorals 
{
    // Main driver method
    public static void main(String[] args)
    {
        int n = 6; // Here, n is the size of the Vector
        Vector <Integer> v = new Vector <Integer>(n); // Here, we declare the vector with initial size ‘n.'
        for (int i = 1; i <= n; i++)
            v.add(i); // Here, we Append the new element at the end of the vector.
        // Now, we are going to display the elements
        System.out.println(v); 
        v.remove(2); // Remove element at index 2
        System.out.println(v); // Here, we display the vector after detection
        for (int i = 0; i < v.size(); i++)  // iterating over vector elements using for loop
            System.out.print(v.get(i) + " "); // Print the elements one by one
    }
}

Output of above code:
[1, 2, 3, 4, 5, 6]
[1, 2, 4, 5, 6]
1 2 4 5 6 

On-Demand Application and Services

Along with the time, on-demand apps and services are becoming popular and spreading in the online market like fire. 

What is an On-Demand service and application?  

On-Demand Applications and Services are the software and platforms that fulfil the requirement of customers when they need them. 
The on-demand application acts as the intermediator between the service provider and the customer(who requests service). 

On-demand services are also known as cloud-based services or Software as a Service (SaaS). These services allow the customers to use storage, software, and other resources instantly from anywhere through the Internet in standard web browsers. These services also charge some fees from their users and customers for using their best platforms. 

Nowadays, there are various famous on-demand applications like Zomato, Ola, Netflix, Uber, and Swiggy, which exist in the market.

How do On-demand Applications work?

If you want to use on-demand applications, first, you have to log in to your account and place an order for the service you want. Then, on-demand applications connect you with on-demand service providers. 

After that, the service provider accepts the request and delivers the service at your preferred location. And, at last, you pay the amount for using the service. You can also pay using an online transaction at the time of placing an order. 

Following are the three categories of on-demand apps and services which are categorized on the basis of the business model:
1. Business to Business (B2B)
2. Business to Customer (B2C)
3. Customer to Customer (C2C)

Types of On-Demand Service Applications

1. Transportation: On-demand app is a big benefit for the transport industries. Unlike traditional taxi services, on-demand transport applications like OLA, UBER, and LYFT make transport more comfortable and convenient.
2. Food: It is one of the most famous on-demand services. UberEat, Zomato, and Swiggy are the famous platforms from which we can order food as per the need.
3. Health care: Healthcare is also an on-demand application which is very useful for patients.

Vim Tutorial

In this article, we will discuss about Vim Text Editor in detail with its features, commands, modes, advantages and disadvantages. Here, you will also learn how to install Vim on Windows and Linux (Ubuntu) Operating system. 
Vim Text Editor Cover

What is Vim?

Vim is a short form of Vi IMproved. This editor is one of the most famous text editor in today’s era.
It is an open-source software and everyone can use it freely. Vim editor is released under a license, which is suitable with the GNU General Public License.
This text editor is used for the command-line, which creates and views the text files. This text editor is an advanced version of Vi. Like the Vi editor, this software is also a command-centric editor.

It is introduced by Bram Moolenaar on 2nd November in the year of 1991. This text editor is developed in C programming language and Vim Script. It is developed to allow the efficient text editing. It is also designed to use as a standalone application in a GUI ( Graphical User Interface ).

This text editor is also especially suited for editing the programs of a computer. It is available on the following platforms:
1. Windows
2. Linux
3. Mac OS
4. Unix
In the year of 2006, this software is voted as a most popular text editor. And in the year of 2019, it became the 5th most popular development environment.

Why Use Vim?

Following are the various why you should use Vim as a text editor:
1. You can easily remember the commands of Vim editor using simple mnemonics. Some commands like i, d, and q which are used to insert, delete and quit. These commands are easy to learn as compared to commands in other editors.
2. This text editor includes the syntax highlighting.
3. You can easily use the Vim with GUI as well as TUI.
4. Vim text editor is cross-platform. Means, it is available on Linux, Windows, Unix, and Mac operations systems. If we have learnt once how to use Vim, then we can easily run it on any platform.
5. Vim allows users to do things quickly and simply. If you know that how it works, then you can easily and quickly make complex edits.
6. The main and important reason to use is Ubiquitous.

Features of Vim

Following are the various features or characteristics, which are provided by the Vim text editor:
1. You can easily undo the last change by using the u command in the command mode.
2. The % (percentage) feature which helps the programmers in the different ways.
3. You can easily repeat the last change in the normal mode by using the (.) command.
4. It also allows a programmer to open the multiple windows for opening the multiple files at the same time.
5. In the normal mode, CTRL + W option allows you to open the same file in another split window.
6. It also allows you to execute the terminal commands from the vim without closing a file.
7. Sometimes, there is a need to find the next or previous occurrences of a word in the text file. So, vim text editor also provides the two different commands (# or *) for finding the next or previous occurrences.

Installation of Vim

You can easily install the Vim on a different platforms or operating systems. Here, we will describe the installation of Vim on Windows system and Ubuntu-based Linux operating system step-by-step.

Installation of Vim on Windows

This software does not need any particular requirement, so you can start installation using the following steps which help to run Vim on Windows operating system:

Step 1: First you have to download the Vim from the following site:
https://www.vim.org/

Vim site

Step 2: Then, click on the download option which is available in the left pane of the site as shown in the above screenshot.
Step 3: Now, click on the gvim_9.0.0000.exe file which is a current version for Windows as shown below.
Vim file

Step 4: Now, the .exe file starts to download. And, after downloading, open .exe file from the Downloads folder.
Step 5: Now, you have to follow the instructions to complete the installation. So, first click the Run button. Then, you have to click Next button to start installation as shown in below picture:
Installation

Step 6: In this step, you have to accept the license by clicking on the I Agree button as shown in the following snapshot:
Agreement

Step 7: Now, select all options from the given drop-down list.
select options

Step 8: After selecting, you have to select that directory in the computer where you want to keep or store the Vim folder. You can achieve this by clicking on the Browse button. Then, click on the Install button.
Store Vim

Step 9: Now, the vim installation will start as shown in the following screenshot.
Vim Install

Step 10: After the installation, there is a pop up on the screen which asks you to see the readme file. If you want to see that file then click Yes otherwise click No. Now, you can easily run Vim from the cmd, i.e., command prompt. To run Vim text editor type the following command in command Prompt:
Vim

Installation of Vim on Ubuntu-Based Linux System

If you want to install the Vim text editor on Ubuntu 18.04 operating system, you have to follow the steps which are given below:
Step 1: First you have to open the terminal using the keyboard shortcut key ( Ctrl + Alt + T ).
Terminal
Step 2: After then, you have to type the following command with the Sudo privileges:
sudo apt-get install Vim
Command
Step 3: Now, you have to type the password of your system. And, you have to type 'Y' each time when it asks during installation.
Installation

Step 4: After installation, you can search Vim with the help of search bar and open it.
Vim

Step 5: At last, you will notice that Vim is successfully installed in your system.
Vim installed

Commands of Vim Editor

Following are the various type of commands which helps us easy to use the Vim editor in the systems:
1. Basic Vim Commands
2. Commands for Cursor Movements
3. Commands for Editing
4. Commands for Inserting and Appending
5. Commands for Searching and Replacing Text
6. Visual Commands
7. Commands for Working with Multiple Files
8. Other Useful Commands

Basic Vim Commands

These type of commands helps users for opening and closing the documents or files and allows them saving them also. These commands are so simple. 

Commands

Description

:e <file_name>

This command opens the specified txt file in Vim editor. If the file does not exist in the system then it creates a new file with the given name.

:help <keyword>

This command shows the relevant information for the keyword which is entered in the command.

:w

This command save that file which is currently working.

:w <filename>

This command allows us to save the current file with a specific name.

:wq or :x

This command saves the current file and then exits the Vim editor.

:q

This command exits the current window of Vim.

:q!

This command allows us to quits the Vim text editor without saving.

ZQ

This command also quits the Vim editor without checking the changes. It is also same as q!.


Commands for Cursor Movements

These following commands help us to move the cursor in the entire file or document. These all commands are used in the command mode.

S.No.

Commands

Description

1.

b

This Vim command moves the cursor at the starting of the previous word. This command cannot move the cursor at the start, if the word contains punctuation marks.

2

B

This command moves the cursor at the beginning of word if the word contains punctuation marks.

3.

e

This Vim command moves the cursor at the last of the next word. It cannot moves the cursor at the end, if the word contain punctuation marks.

E

This Vim command also moves the cursor at the last of the current word but if the word contains punctuation marks.

fx

This command moves the cursor forwards to the first occurrence of the letter 'x' in the same line.

Fx

This command moves the cursor backwards to the first occurrence of the letter 'x' in the same line.

G

This Vim command moves the cursor at the starting of the last line in the current document or file.

gg

This command moves the cursor at the starting of the first line in the document or file.

g_

This command moves the cursor in the current line to the last character which is non-blank.

10.

h

This Vim command moves the cursor to the left of next letter.

11.

H

This Vim command moves the cursor at the first line of the current screen.

12.

j

This command moves the cursor down only one line.

13.

k

This Vim command moves the cursor to the upper line on the exact position.

14. 

l

This Vim command moves the cursor to the right of next letter.

15.

L

This Vim command moves the cursor at the last line of the current screen.

16.

M

This Vim command moves the cursor to the middle or midline of the current screen.

17.

w

This command moves the character at the beginning of the next word. This command cannot move the cursor at the start of the next word if the current word contains punctuation marks.

18.

W

This Vim command moves the cursor at the beginning of the next word when the word contains punctuation marks only.

19.

0

This Vim command moves the cursor at the beginning of the current line.

20.

^

This vim command moves the cursor in the current line to the first character which is non-blank.

21.

$

This Vim command moves the cursor to the last character in the current line if the character is either blank or non-blank.

22.

)

This Vim command moves the cursor to the begin of the next sentence.

23.

(

This Vim command moves the cursor to the begin of the previous sentence.

24.

{

This Vim command moves the cursor to the beginning of the previous paragraph or a text block.

25.

}

This Vim command moves the cursor to the beginning of the next text block or a paragraph.

26.

Ctrl + e

This shortcut key moves the screen down only one line. It does not move the cursor.

27.

Ctrl + y

This shortcut key moves the screen up one line. This command

28.

Ctrl + d

This shortcut key scrolls or moves forward half (1/2) a terminal screen.

29.

Ctrl + u

This shortcut key scrolls or moves back half (1/2) a terminal screen.

30.

Ctrl + f

This shortcut key scrolls or moves forward full terminal screen.

31.

Ctrl + b

This shortcut key scrolls or moves back full terminal screen.


Commands for Editing

Vim text editor provides the various following features which allows users to edit their documents in an easy and effective way. The following table gives the various commands for editing:

S. No

Commands

Description

1. 

. (dot)

This command is used to repeat that command which is recently executed.

2. 

C

This Vim command deletes all the characters or words after the current position of the cursor and takes us to Insert Mode for inserting the new text.

3. 

cc

This command deletes all the characters (whole line) in that line in which cursor is current present. And then, takes us to Insert Mode for inserting the new text.

4. 

ciw

This Vim command deletes the entire word in which the cursor is currently see. And then, takes us to Insert Mode for inserting the new text.

5.

cw

This command deletes all the characters from the current position of the cursor till the last character of the word. And then, takes us to Insert Mode for inserting the new text.

6.

D

This Vim command removes all blank and non-blank characters from the current position of the cursor in the current line.

7.

dd

This Vim command deletes the entire line in which the cursor is currently available.

8.

ndd

This command deletes nth line.

9.

dw

This Vim command deletes the characters from the current position of the cursor till the begin of the next word.

10.

d-

This command deletes the current line and the line which is present above the current line.

11.

dfd

This Vim command deletes all the characters between the current position of the cursor and the first occurrence of the letter 'd'. It also removes 'd' character and the character from the current position of the cursor.

12.

db

This Vim command deletes the characters from the starting of the word till the current position of the cursor.

13.

d^

This Vim command deletes the characters from the first non-blank character of the current line to the current position of the cursor.

14.

gJ

This command joins the below line at the end of the current line without giving space between them.

15.

J

This command joins the below line with the current line by giving one space between them.

16.

r

This Vim command replaces the current position of the cursor.

17.

s

This command deletes the character and substitute text. And, then takes us to the Insert Mode.

18.

S

This command works the same as cc command.

19.

u

This command is used for undo operation.

20.

X

This command deletes only one character from the left of the cursor.

21.

x

This command deletes the character from the current position of the cursor.

22.

Ctrl + r

This shortcut key is used for redo operation.


Commands for Inserting and Appending

Vim text editor provides the following commands which allow the users to insert and append the characters or words at the different positions in the current working document or file:

S. No

Commands

Description

a

This command appends the characters or words after the cursor.

A

This command appends the text to the end of the current line. When we use this command, Vim automatically takes to the Insert mode allows us to append the text. Press Esc command for terminating the Insert Mode.

ea

This command appends the text to the end of the current or next upcoming word in the current line of a file or document.

Esc

This command exits or terminates the Insert mode.

i

This command inserts the text at the current position of the cursor.

I

This command inserts the text at the beginning of the current line.

o

This command opens a new line for appending the text below the line in which cursor is currently present.

O

This command opens a new line for appending the text above the line in which cursor is currently present.


Commands for Searching and Replacing Text


S. No

Commands

Description

n

This command searches the item in the same direction of the last search.

N

This command searches the item in the opposite direction of the last search.

/word

This command searches the given word from top to bottom in the file or document.

?word

This command searches the given word from bottom to top in the file or document.

/j[ts]p

This command searches the word 'jtp' or 'jsp'. This command specifies a word which is come first in searching.

/ \<or

This command searches the word like or, oracle, orange, etc in the file.

:%s/old/new/g

This command replaces all the given old words with the given new word throughout the file.

:%s/old/new/gc

This command asks for confirmation replaces all the given old words with the given new word throughout the file.

:s/old/new/gi

This command replaces all the old words or characters with the new given words or characters within a single line.

:1,10s/old_text/new_text/g

This command replaces all the old words or characters with the new given words or characters within a specified range of lines.





Visual Commands

The following table provides some visual commands. To move in a visual mode, we have to press v.

S. No

Commands

Description

>>

This command shifts the text right.

<<

This command shifts the text left.

~

This command changes the case of an individual character. Means, if the character is in lowercase, this command change into uppercase and vice-versa.

d

This command removes the marked text.

y

This command copies the marked text.

p

This command pastes the text which is copied by the ‘y’ command.


Commands for Working with Multiple Files

Vim also provides the following features which help users for editing multiple files at a time.

S. No

Commands

Description

:bd

This command deletes or closes the current buffer.

:bn or :bnext

This command allows us to move to the next buffer.

:bp or :brev

This command allows us to move to the previous buffer.

:e file

This command allows us to edit the file in the new buffer.

:ls

This command allows us to open the list of all buffers.

:sp file

This command allows us to open a file in the new buffer and splitting window.

:vsp file

This command allows us to open a file in new buffer and splitting window in vertical.

Ctrl + ws

This command is used for splitting the window screen.

Ctrl + ww

This command is used for switching the windows.

Ctrl + wq

This command exits or quits a window.

Ctrl + wv

This command is used for splitting the window vertically.

Ctrl+ wh

This command is used for moving the cursor to the left window when the window is vertically split.

Ctrl + wl

This command is used for moving the cursor to the right window when the window is vertically split.

Ctrl + wj

This command is used for moving the cursor to the below window when the window is horizontally split.

Ctrl + wk

This command is used for moving the cursor to the above window when the window is horizontally split.


Vim Modes 

Vim text editor provides the following various modes, which help users to run the Vim software:
1. Command Mode (Normal Mode)
2. Insert Mode 
3. Visual Mode

Normal Mode

This mode is also known as command mode. This mode is used for editing and saving the text file or document.  
When we open the Vim, then this mode will be opened as a default mode. If we are in any other mode and we want to move to this mode then we have to press only the Escape ( Esc ) key from the keyboard.
If we are already in this mode, and we pressed the Escape key from the keyboard then Vim editor will beep and flash the screen.

This mode enables users to copy, paste, or delete a piece of text in the file or document. Using this mode, we can also use the last line commands which begin with the colon (:) sign. This mode also save the changes which are done by us in a file.

Insert Mode

This mode allows users for entering and editing the text. When we are in Insert Mode, then we can easily type or insert the character just like the other regular text editors. 

If we are in any other mode and want to move on this mode then we have to press ‘i’ key from the keyboard. When we enter any character in this mode then that character is inserted as an input to the current working file. If we want to move to command mode, then we have to press the Esc key. 

Visual Mode

This mode is the same as the command mode but in this mode, we can easily select the text and then run commands on the selected text. If we are in any other mode and want to move to this mode then we have to press only ‘v’  key from the keyboard. 
Following are the three types of Visual mode:
1. Plain Visual Mode
2. Block Visual Mode
3. Line-wise Visual Model

Start Vim

If Vim is already installed in your system, then you can easily launch the Vim text editor using the following steps, otherwise, you have to install it on your ubuntu system.
Step 1: Open the terminal using Ctrl + Alt + T shortcut key.  
terminal

Step 2: Now, type the following command to start the Vim text editor in terminal and you will see the below screen on your system:
Vim

Vim_Terminal

Step 3: The above screen will open in a command mode by default. Now, you have to open the new file or existing file using the following command:
:e <file_name>


openfile

Step 4: The file is automatically open in the Command mode.
Vim_new file

For inserting the text into the file you have to press the 'i' key, so that the file will open in an Insert Mode. 
Insert mode

Step 5: Now, you have to insert the data or information into the file by key. Everything you have typed is inserted automatically in the file. 
Inserted_Data

When the data is successfully inserted, press Esc button to move back to Command Mode. The following screen shows the command mode: 
command mode

Step 6: In the command mode, you have to type the ':wq' command to save the file in the system and to close Vim editor.
Save File

Step 7: You can see your file with the help of following cat command:
cat <file_name>

Cat command

Advantages of Vim

Following are the various advantages or benefits of Vim text editor:
    • Open-source software: This software is not only a free, but it is also available for all the operating systems in any one of the Terminal mode or GUI mode. It is also suitable with the GPL charityware.      
    • We can easily perform the complex tasks which are related to text with the few commands given by Vim. 
    • This text editor is highly configurable.   
    • This text editor is very popular in the Linux or Unix word.    
    • As compared to other editors which are good in graphics like Sublime and Atom, it is fast. This text editor is also faster than Emacs. 
    • This editor is also working in a terminal over SSH. 
    • We do need to use the mouse and Ctrl/Alt keyboard buttons again, because it provides the mouse-free interface. It is keyboard-based and also supported by the trackpad.
    • If we want to log into SSH, we can easily run Vim with a terminal and also with the GUI.  
    • It is light-weighted, compact and excellent performance, because, it easily and quickly replaces all the occurrences of the string in the files which are more than 100 MB. 
    • In this text editor, everything is mnemonic, because there is a series of actions, or verbs or nouns. So, mnemonic makes it easy to use easily. 
    • It provides the multiples distinct modes for the editing. Following are some editing modes:
        ◦ Normal Mode
        ◦ Command Mode
        ◦ Visual Mode
        ◦ Insert mode

Disadvantages of Vim

Following are the various disadvantages or limitations of Vim text editor:
    • This text editor is difficult to use for the beginners. 
    • There is a difficulty to learn all the command and modes which are supported in Vim. So, we have spent a lot of time in learning.
    • This editor takes some minutes to open those files which contain a lot of very long lines, but other few text editors can load the same file in a few seconds. 
    • In this text editor, when working with the large files there is no smooth scrolling. 
    • It consumes the energy of the brain for editing, which should be basically used for the logics. 
    • In this text editor, it is difficult to copy, paste and delete the text.